package rapidservice.service;

import com.rapidservice.types.Item;
import com.rapidservice.types.Quote;
import javax.ejb.Stateless;
import javax.jws.WebService;


@WebService(name = "RapidService", serviceName = "RapidService")
@Stateless()
public class RapidServiceImplementation {
    public RapidServiceImplementation() {
    }
    
    public Quote processQuote(String orderId, Item[] items) {
        Long totalPrice = new Long(0);
        for (int i = 0; i < items.length; i++) {
            Item localItem = items[i];
            totalPrice += localItem.getQuantity() * (((Long.valueOf(orderId) % 2) != 0) ? 250 : 1);
        }
        Quote priceQuote = new Quote();
        priceQuote.setSupplierPrice(totalPrice.toString());
        
        System.out.println("Cotizacion RapidService --- Orden " + orderId + " Valor  " + totalPrice);
        
        return priceQuote;

    }
    
    public boolean orderQuoute(String orderId){
        return true;
    }
}
